<?php
/**
 * 区域管理
 *
 * @copyright   Copyright 2011, Richie
 * @author      Richie <richbossman@163.com>
 * @package     SMS
 * @link        http://www.letphp.com
 * 
 * $Id: RegionAction.class.php 52 2011-03-24 15:00:25Z 442767452@qq.com $
 */
class RegionAction extends SMSAction {
	
	function _before_select(){
		$pid = isset($_GET['id']) ? intval($_GET['id']) : 0;
		$a = array ('province' => 'city', 'city' => 'district', 'district' => 'd' );
		$t = isset ( $_GET ['type'] ) ? trim ( $_GET ['type'] ) : 'province';
		$type = !empty($t) ? $a[$t] : 'city';
		$_LANG ['pleasechose'] = '请选择';
		$_LANG ['province'] = '省份';
		$_LANG ['city'] = '城市';
		$_LANG ['district'] = '街区';

		if(empty($pid)){
			$list = array();
		}else{
			$list = D('Region')->getList($pid);
		}
		$html = '';
		if ($list) {
			$html .= '<select id="' . $t . '" name="' . $t . '" ';
			if ($type)
				$html .= 'onChange="selectRegion(\'' . $type . '\', \'' . $t . '\')">';
			$html .= '<option value="0">' . $_LANG ['pleasechose'] . $_LANG [$t] . '</option>';
			foreach ( $list as $key=>$area ) {
				$html .= '<option value="' . $key . '">' . $area . '</option>';
			}
			$html .= '</select>';
		}
		$this->success($html, array('type'=>$t));
	}
	
	function select(){
		
	}
}
?>